package org.example.iris.mapper;

import org.apache.ibatis.annotations.*;
import org.example.iris.dto.ApplicationInfo;

import java.util.List;

import org.example.iris.entity.Application;

@Mapper
public interface ApplicationMapper {

    @Update("UPDATE application SET status = #{status} WHERE application_id = #{applicationId}")
    void updateApplicationStatus(@Param("applicationId") int applicationId, @Param("status") String status);

    /**
     * 获取指定岗位的所有申请ID
     * @param jobId 岗位ID
     * @return 申请ID列表
     */
    @Select("SELECT application_id, student_id FROM application WHERE job_id = #{jobId}")
    List<ApplicationInfo> getApplicationIdsAndStudentIdsByJobId(@Param("jobId") int jobId);

    @Insert("insert into application(student_id, company_id, job_id, status, date, file_id) " +
            "values(#{studentId}, #{companyId}, #{jobId}, #{status}, now(), #{fileId})")
    void insertApplication(Application application);

    @Select("SELECT * FROM application WHERE student_id = #{studentId}")
    List<Application> getApplicationByStudentId(Integer studentId);

    @Delete("DELETE FROM application WHERE application_id = #{applicationId}")
    void deleteApplication(Integer applicationId);
}
